/*
 * sme_api.h
 *
 * Copyright(C) 2002 Winbond Electronics Corp.
 *
 * modification history
 * ---------------------------------------------------------------------------
 * 1.00.001, 2003-04-21, Kevin       created
 * 1.00.002, 2003-05-14, PD43 & PE20 modified
 *
 */

#ifndef __SME_API_H__
#define __SME_API_H__

/****************** INCLUDE FILES SECTION ***********************************/
//#include "GL\gl_core.h"

/****************** CONSTANT AND MACRO SECTION ******************************/
#define _INLINE      __inline

#define MEDIA_STATE_DISCONNECTED    0
#define MEDIA_STATE_CONNECTED       1

//ARRAY CHECK
#define MAX_POWER_TO_DB 32

/****************** TYPE DEFINITION SECTION *********************************/

/****************** EXPORTED FUNCTION DECLARATION SECTION *******************/

// OID_802_11_BSSID
CHAR sme_get_bssid(void *pcore_data, UCHAR *pbssid);
CHAR sme_get_desired_bssid(void *pcore_data, UCHAR *pbssid);//Not use
CHAR sme_set_desired_bssid(void *pcore_data, UCHAR *pbssid);

// OID_802_11_SSID
CHAR sme_get_ssid(void *pcore_data, UCHAR *pssid, UCHAR *pssid_len);
CHAR sme_get_desired_ssid(void *pcore_data, UCHAR *pssid, UCHAR *pssid_len);// Not use
CHAR sme_set_desired_ssid(void *pcore_data, UCHAR *pssid, UCHAR ssid_len);

// OID_802_11_INFRASTRUCTURE_MODE
CHAR sme_get_bss_type(void *pcore_data, UCHAR *pbss_type);
CHAR sme_get_desired_bss_type(void *pcore_data, UCHAR *pbss_type);//Not use
CHAR sme_set_desired_bss_type(void *pcore_data, UCHAR bss_type);

// OID_802_11_FRAGMENTATION_THRESHOLD
CHAR sme_get_fragment_threshold(void *pcore_data, ULONG *pthreshold);
CHAR sme_set_fragment_threshold(void *pcore_data, ULONG threshold);

// OID_802_11_RTS_THRESHOLD
CHAR sme_get_rts_threshold(void *pcore_data, ULONG *pthreshold);
CHAR sme_set_rts_threshold(void *pcore_data, ULONG threshold);

// OID_802_11_RSSI
CHAR sme_get_rssi(void *pcore_data, LONG *prssi);

// OID_802_11_CONFIGURATION
CHAR sme_get_beacon_period(void *pcore_data, USHORT *pbeacon_period);
CHAR sme_set_beacon_period(void *pcore_data, USHORT beacon_period);

CHAR sme_get_atim_window(void *pcore_data, USHORT *patim_window);
CHAR sme_set_atim_window(void *pcore_data, USHORT atim_window);

CHAR sme_get_current_channel(void *pcore_data, UCHAR *pcurrent_channel);
CHAR sme_get_current_band(void *pcore_data, UCHAR *pcurrent_band);
CHAR sme_set_current_channel(void *pcore_data, UCHAR current_channel);

// OID_802_11_BSSID_LIST
CHAR sme_get_scan_bss_count(void *pcore_data, UCHAR *pcount);
CHAR sme_get_scan_bss(void *pcore_data, UCHAR index, void **ppbss); 

CHAR sme_get_connected_bss(void *pcore_data, void **ppbss_now);

// OID_802_11_AUTHENTICATION_MODE
CHAR sme_get_auth_mode(void *pcore_data, UCHAR *pauth_mode);
CHAR sme_set_auth_mode(void *pcore_data, UCHAR auth_mode);

// OID_802_11_WEP_STATUS / OID_802_11_ENCRYPTION_STATUS
CHAR sme_get_wep_mode(void *pcore_data, UCHAR *pwep_mode);
CHAR sme_set_wep_mode(void *pcore_data, UCHAR wep_mode);
//CHAR sme_get_encryption_status(void *pcore_data, UCHAR *pstatus);
//CHAR sme_set_encryption_status(void *pcore_data, UCHAR status);

// ???????????????????????????????????????

// OID_GEN_VENDOR_ID
// OID_802_3_PERMANENT_ADDRESS
CHAR sme_get_permanent_mac_addr(void *pcore_data, UCHAR *pmac_addr);

// OID_802_3_CURRENT_ADDRESS
CHAR sme_get_current_mac_addr(void *pcore_data, UCHAR *pmac_addr);

// OID_802_11_NETWORK_TYPE_IN_USE
CHAR sme_get_network_type_in_use(void *pcore_data, UCHAR *ptype);
CHAR sme_set_network_type_in_use(void *pcore_data, UCHAR type);

// OID_802_11_SUPPORTED_RATES
CHAR sme_get_supported_rate(void *pcore_data, UCHAR *prates);

// OID_802_11_ADD_WEP
//12/29/03' wkchen
CHAR sme_set_add_wep(void *pcore_data, ULONG key_index, ULONG key_len,
					 UCHAR *Address, UCHAR *key);

// OID_802_11_REMOVE_WEP
CHAR sme_set_remove_wep(void *pcre_data, ULONG key_index);

// OID_802_11_DISASSOCIATE
CHAR sme_set_disassociate(void *pcore_data);

// OID_802_11_POWER_MODE
CHAR sme_get_power_mode(void *pcore_data, UCHAR *pmode);
CHAR sme_set_power_mode(void *pcore_data, UCHAR mode);

// OID_802_11_BSSID_LIST_SCAN
CHAR sme_set_bssid_list_scan(void *pcore_data, void *pscan_para);

// OID_802_11_RELOAD_DEFAULTS
CHAR sme_set_reload_defaults(void *pcore_data, UCHAR reload_type);


// The following SME API functions are used for WPA
//
// Mandatory OIDs for WPA
//

// OID_802_11_ADD_KEY
//CHAR sme_set_add_key(void *pcore_data, NDIS_802_11_KEY *pkey);

// OID_802_11_REMOVE_KEY
//CHAR sme_set_remove_key(void *pcore_data, NDIS_802_11_REMOVE_KEY *pkey);

// OID_802_11_ASSOCIATION_INFORMATION
//CHAR sme_set_association_information(void *pcore_data,
//                    NDIS_802_11_ASSOCIATION_INFORMATION *pinfo);

// OID_802_11_TEST
//CHAR sme_set_test(void *pcore_data, NDIS_802_11_TEST *ptest_data);

//--------------------------------------------------------------------------//
/*
// The left OIDs

// OID_802_11_NETWORK_TYPES_SUPPORTED 
// OID_802_11_TX_POWER_LEVEL
// OID_802_11_RSSI_TRIGGER
// OID_802_11_NUMBER_OF_ANTENNAS
// OID_802_11_RX_ANTENNA_SELECTED
// OID_802_11_TX_ANTENNA_SELECTED
// OID_802_11_STATISTICS
// OID_802_11_DESIRED_RATES
// OID_802_11_PRIVACY_FILTER

*/

/*------------------------- none-standard ----------------------------------*/
CHAR sme_get_connect_status(void *pcore_data, UCHAR *pstatus);

/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
//CHAR sme_get_scan_type(void *pcore_data, UCHAR *pscan_type);
//CHAR sme_set_scan_type(void *pcore_data, UCHAR scan_type);

//CHAR sme_get_scan_channel_list(void *pcore_data, UCHAR *pscan_type);
//CHAR sme_set_scan_channel_list(void *pcore_data, UCHAR scan_type);


void sme_get_encryption_status(void *pcore_data, UCHAR *EncryptStatus);
void sme_set_encryption_status(void *pcore_data, UCHAR EncryptStatus);
CHAR sme_add_key(void		*pcore_data,
					ULONG		key_index,
					UCHAR		key_len,
					UCHAR		key_type,
					UCHAR		*key_bssid,
					//UCHAR		*key_rsc,
					UCHAR		*ptx_tsc,
					UCHAR		*prx_tsc,
					UCHAR		*key_material);
void sme_remove_default_key(void *pcore_data, int index);
void sme_remove_mapping_key(void *pcore_data, UCHAR *pmac_addr);
void sme_clear_all_mapping_key(void *pcore_data);
void sme_clear_all_default_key(void *pcore_data);



CHAR sme_set_preamble_mode(void *pcore_data, UCHAR mode);
CHAR sme_get_preamble_mode(void *pcore_data, UCHAR *mode);
CHAR sme_get_preamble_type(void *pcore_data, UCHAR *type);
CHAR sme_set_slottime_mode(void *pcore_data, UCHAR mode);
CHAR sme_get_slottime_mode(void *pcore_data, UCHAR *mode);
CHAR sme_get_slottime_type(void *pcore_data, UCHAR *type);
CHAR sme_set_txrate_policy(void *pcore_data, UCHAR policy);
CHAR sme_get_txrate_policy(void *pcore_data, UCHAR *policy);
CHAR sme_get_cwmin_value(void *pcore_data, UCHAR *cwmin);
CHAR sme_get_cwmax_value(void *pcore_data, USHORT *cwmax);
CHAR sme_get_ms_radio_mode(void *pcore_data, UCHAR * pMsRadioOff);
CHAR sme_set_ms_radio_mode(void *pcore_data, UCHAR boMsRadioOff);
CHAR sme_get_radio_mode(void *pcore_data, psRadioOff pRadioOffData);
CHAR sme_set_radio_mode(void *pcore_data, RadioOff RadioOffData);

void sme_get_tx_power_level(void *pcore_data, ULONG *TxPower);
UCHAR sme_set_tx_power_level(void *pcore_data, ULONG TxPower);
void sme_get_antenna_count(void *pcore_data, ULONG *AntennaCount);
void sme_get_rx_antenna(void *pcore_data, ULONG *RxAntenna);
UCHAR sme_set_rx_antenna(void *pcore_data, ULONG RxAntenna);
void sme_get_tx_antenna(void *pcore_data, ULONG *TxAntenna);
CHAR sme_set_tx_antenna(void *pcore_data, ULONG TxAntenna);
CHAR sme_set_IBSS_chan(void *pcore_data, ChanInfo chan);

//20061108 WPS
CHAR sme_set_IE_append(void *pcore_data, PUCHAR buffer, USHORT buf_len);




//================== Local functions ======================
//#ifdef _HSINCHU
//void drv_translate_rssi();   // HW RSSI bit -> NDIS RSSI representation
//void drv_translate_bss_description(); // Local bss desc -> NDIS bss desc
//void drv_translate_channel(UCHAR NetworkType, UCHAR ChannelNumber, ULONG *freq); // channel number -> channel /freq.
//#endif _HSINCHU
//
static const ULONG PowerDbToMw[] =
{
	56,	//mW, MAX - 0,	17.5 dbm
	40,	//mW, MAX - 1,	16.0 dbm
	30,	//mW, MAX - 2,	14.8 dbm
	20,	//mW, MAX - 3,	13.0 dbm
	15,	//mW, MAX - 4,	11.8 dbm
	12,	//mW, MAX - 5,	10.6 dbm
	9,	//mW, MAX - 6,	 9.4 dbm
	7,	//mW, MAX - 7,	 8.3 dbm
	5,	//mW, MAX - 8,	 6.4 dbm
	4,	//mW, MAX - 9,	 5.3 dbm
	3,	//mW, MAX - 10,  4.0 dbm
	2,	//mW, MAX - 11,  ? dbm
	2,	//mW, MAX - 12,  ? dbm
	2,	//mW, MAX - 13,  ? dbm
	2,	//mW, MAX - 14,  ? dbm
	2,	//mW, MAX - 15,  ? dbm
	2,	//mW, MAX - 16,  ? dbm
	2,	//mW, MAX - 17,  ? dbm
	2,	//mW, MAX - 18,  ? dbm
	1,	//mW, MAX - 19,  ? dbm
	1,	//mW, MAX - 20,  ? dbm
	1,	//mW, MAX - 21,  ? dbm
	1,	//mW, MAX - 22,  ? dbm
	1,	//mW, MAX - 23,  ? dbm
	1,	//mW, MAX - 24,  ? dbm
	1,	//mW, MAX - 25,  ? dbm
	1,	//mW, MAX - 26,  ? dbm
	1,	//mW, MAX - 27,  ? dbm
	1,	//mW, MAX - 28,  ? dbm
	1,	//mW, MAX - 29,  ? dbm
	1,	//mW, MAX - 30,  ? dbm
	1	//mW, MAX - 31,  ? dbm
};





#endif /* __SME_API_H__ */


